<!DOCTYPE html>
<!-- saved from url=(0041)http://c.biancheng.net/view/vip_7067.html -->
<html lang="zh-CN"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><script type="text/javascript" async="" charset="utf-8" src="./9.6Java中为什么使用向上转型而不直接创建子类对象？_files/core.php"></script><script async="" src="./9.6Java中为什么使用向上转型而不直接创建子类对象？_files/click.php"></script>

<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
<!-- 启用Chromium高速渲染模式 -->
<meta name="renderer" content="webkit">
<meta name="force-rendering" content="webkit">
<!-- 禁止百度转码 -->
<meta name="applicable-device" content="pc,mobile">
<meta name="MobileOptimized" content="width">
<meta name="HandheldFriendly" content="true">
<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
<!-- 禁止识别电话号码 -->
<meta name="format-detection" content="telephone=no">

<link rel="shortcut icon" href="http://c.biancheng.net/favicon.ico?v=1.6.72">
<link href="./9.6Java中为什么使用向上转型而不直接创建子类对象？_files/common.css" rel="stylesheet">
<title>Java中为什么使用向上转型而不直接创建子类对象？</title>
<meta name="description" content="初学者在学习向上转型可能会很难理解，向上转型并不能调用子类特有属性和方法，我们必须先生成子类实例再赋值给父类引用（向上转型），然后将父类引用向下强制转换给子类引用">
</head>
<body>
<div id="topbar" class="clearfix">
	<ul id="product-type" class="left">
		<li>
			<a href="http://c.biancheng.net/"><span class="iconfont iconfont-home"></span>首页</a>
		</li>
		<li class="active">
			<a href="http://c.biancheng.net/sitemap/" rel="nofollow"><span class="iconfont iconfont-book"></span>教程</a>
		</li>
		<li>
			<a href="http://vip.biancheng.net/p/vip/show.php" rel="nofollow" target="_blank"><span class="iconfont iconfont-vip"></span>VIP会员</a>
		</li>
		<li>
			<a href="http://vip.biancheng.net/p/q2a/show.php" rel="nofollow" target="_blank"><span class="iconfont iconfont-q2a"></span>一对一答疑</a>
		</li>
		<li>
			<a href="http://fudao.biancheng.net/" rel="nofollow" target="_blank"><span class="iconfont iconfont-fudao"></span>辅导班</a>
		</li>
	</ul>
</div>
<div id="header" class="clearfix">
	<a id="logo" class="left" href="http://c.biancheng.net/">
		<img height="26" src="./9.6Java中为什么使用向上转型而不直接创建子类对象？_files/logo.png" alt="C语言中文网">
	</a>
	<ul id="nav-main" class="hover-none left clearfix">
		<li class="wap-yes"><a href="http://c.biancheng.net/">首页</a></li>
		<li><a href="http://c.biancheng.net/c/">C语言教程</a></li>
		<li><a href="http://c.biancheng.net/cplus/">C++教程</a></li>
		<li><a href="http://c.biancheng.net/python/">Python教程</a></li>
		<li><a href="http://c.biancheng.net/java/">Java教程</a></li>
		<li><a href="http://c.biancheng.net/linux_tutorial/">Linux入门</a></li>
		<li><a href="http://c.biancheng.net/sitemap/" title="网站地图">更多&gt;&gt;</a></li>
	</ul>
	<span id="sidebar-toggle" class="toggle-btn" toggle-target="#sidebar">目录 <span class="glyphicon"></span></span>

	<a href="http://vip.biancheng.net/?from=topbar" class="user-info glyphicon glyphicon-user hover-none" target="_blank" rel="nofollow" title="用户中心"></a>
</div>
<div id="main" class="clearfix">
	<div id="sidebar" class="toggle-target">
	<div id="contents">
		<dt><span class="glyphicon glyphicon-option-vertical" aria-hidden="true"></span><a href="http://c.biancheng.net/java/">Java教程</a></dt>
		
			<dd>
				<span class="channel-num">1</span>
				<a href="http://c.biancheng.net/java/10/">Java入门基础及环境搭建</a>
			</dd>
		
			<dd>
				<span class="channel-num">2</span>
				<a href="http://c.biancheng.net/java/20/">Java程序设计基础</a>
			</dd>
		
			<dd>
				<span class="channel-num">3</span>
				<a href="http://c.biancheng.net/java/30/">Java流程控制语句</a>
			</dd>
		
			<dd>
				<span class="channel-num">4</span>
				<a href="http://c.biancheng.net/java/40/">Java字符串处理</a>
			</dd>
		
			<dd>
				<span class="channel-num">5</span>
				<a href="http://c.biancheng.net/java/50/">Java数字和日期处理</a>
			</dd>
		
			<dd>
				<span class="channel-num">6</span>
				<a href="http://c.biancheng.net/java/60/">Java内置包装类</a>
			</dd>
		
			<dd>
				<span class="channel-num">7</span>
				<a href="http://c.biancheng.net/java/70/">Java数组处理</a>
			</dd>
		
			<dd>
				<span class="channel-num">8</span>
				<a href="http://c.biancheng.net/java/80/">Java类和对象</a>
			</dd>
		<dd class="this"> <span class="channel-num">9</span> <a href="http://c.biancheng.net/java/90/">Java继承和多态</a> </dd><dl class="dl-sub"><dd>9.1 <a href="http://c.biancheng.net/view/986.html">Java类的封装</a></dd><dd>9.2 <a href="http://c.biancheng.net/view/987.html">Java封装图书信息类</a></dd><dd>9.3 <a href="http://c.biancheng.net/view/6398.html">Java继承简明教程</a></dd><dd>9.4 <a href="http://c.biancheng.net/view/6394.html">Java super关键字</a></dd><dd>9.5 <a href="http://c.biancheng.net/view/6503.html">Java对象类型转换</a></dd><dd class="active">9.6 <a href="http://c.biancheng.net/view/vip_7067.html">Java中为什么使用向上转型而不直接创建子类对象？</a><span class="glyphicon glyphicon-usd"></span></dd><dd>9.7 <a href="http://c.biancheng.net/view/998.html">Java方法重载</a></dd><dd>9.8 <a href="http://c.biancheng.net/view/1000.html">Java方法重写</a></dd><dd>9.9 <a href="http://c.biancheng.net/view/1001.html">Java多态性</a></dd><dd>9.10 <a href="http://c.biancheng.net/view/6346.html">Java instanceof关键字</a></dd><dd>9.11 <a href="http://c.biancheng.net/view/1004.html">Java抽象类</a></dd><dd>9.12 <a href="http://c.biancheng.net/view/6540.html">Java接口</a></dd><dd>9.13 <a href="http://c.biancheng.net/view/vip_7069.html">Java抽象类和接口的联系和区别</a><span class="glyphicon glyphicon-usd"></span></dd><dd>9.14 <a href="http://c.biancheng.net/view/1022.html">Java内部类简介</a></dd><dd>9.15 <a href="http://c.biancheng.net/view/1025.html">Java实例内部类</a></dd><dd>9.16 <a href="http://c.biancheng.net/view/1026.html">Java静态内部类</a></dd><dd>9.17 <a href="http://c.biancheng.net/view/1028.html">Java局部内部类</a></dd><dd>9.18 <a href="http://c.biancheng.net/view/1031.html">Java匿名类</a></dd><dd>9.19 <a href="http://c.biancheng.net/view/vip_7070.html">Java使用内部类实现多重继承</a><span class="glyphicon glyphicon-usd"></span></dd><dd>9.20 <a href="http://c.biancheng.net/view/6564.html">Java8新特性：Effectively final</a></dd><dd>9.21 <a href="http://c.biancheng.net/view/6393.html">Java Lambda表达式</a></dd><dd>9.22 <a href="http://c.biancheng.net/view/vip_7071.html">Java Lambda表达式的3种简写方式</a><span class="glyphicon glyphicon-usd"></span></dd><dd>9.23 <a href="http://c.biancheng.net/view/6466.html">Java Lambda表达式的使用</a></dd><dd>9.24 <a href="http://c.biancheng.net/view/vip_7072.html">Java Lambda表达式与匿名内部类的联系和区别</a><span class="glyphicon glyphicon-usd"></span></dd></dl>
			<dd>
				<span class="channel-num">10</span>
				<a href="http://c.biancheng.net/java/100/">Java异常处理</a>
			</dd>
		
			<dd>
				<span class="channel-num">11</span>
				<a href="http://c.biancheng.net/java/110/">Java集合、泛型和枚举</a>
			</dd>
		
			<dd>
				<span class="channel-num">12</span>
				<a href="http://c.biancheng.net/java/120/">Java反射机制</a>
			</dd>
		
			<dd>
				<span class="channel-num">13</span>
				<a href="http://c.biancheng.net/java/130/">Java输入/输出流</a>
			</dd>
		
			<dd>
				<span class="channel-num">14</span>
				<a href="http://c.biancheng.net/java/java/135/">Java注解</a>
			</dd>
		
	</div>
</div>
	<div id="article-wrap">
		<div id="article">
			<div class="arc-info">
	<span class="position"><span class="glyphicon glyphicon-map-marker"></span> <a href="http://c.biancheng.net/">首页</a> &gt; <a href="http://c.biancheng.net/java/">Java教程</a> &gt; <a href="http://c.biancheng.net/java/90/">Java继承和多态</a></span>
	<span class="read-num">阅读：6,241</span>
</div>

<div id="ad-position-bottom"></div>
			<h1>Java中为什么使用向上转型而不直接创建子类对象？</h1>
			<div class="pre-next-page clearfix">
                    <span class="pre left"><span class="icon">&lt;</span> <span class="text-brief text-brief-pre">上一页</span><a href="http://c.biancheng.net/view/6503.html">Java对象类型转换</a></span>
                    <span class="next right"><a href="http://c.biancheng.net/view/998.html">Java方法重载</a><span class="text-brief text-brief-next">下一页</span> <span class="icon">&gt;</span></span>
                </div>
			<div id="ad-arc-top"><p class="pic"></p><p class="text" adid="java-1v1q2a"><a href="http://c.biancheng.net/view/7552.html" target="_blank" style="color: #D33428;">C语言中文网推出辅导班啦，包括<span style="color: #008000;">「C语言辅导班、C++辅导班、算法/数据结构辅导班」</span>，全部都是一对一教学：一对一辅导 + 一对一答疑 + 布置作业 + 项目实践 + 永久学习。QQ在线，随时响应！</a></p></div>
			<div id="arc-body">初学者在学习向上转型可能会很难理解，向上转型并不能调用子类特有属性和方法，我们必须先生成子类实例再赋值给父类引用（向上转型），然后将父类引用向下强制转换给子类引用（向下转型），这样才能调用子类中的所有成员。这看起来像是多次一举，还不如直接创建子类实例。<br>
<br>
随着技术的提升，我们在学习其它开源项目时会发现很多地方都用了向上转型和向下转型的技术。本节将带大家了解向上转型和向下转型的意义及使用场景。
<h4>
	例 1</h4>
定义父类 Animal，代码如下：<br>
<div class="snippet-container" style="undefined;"><div class="sh_bright snippet-wrap"><div class="snippet-menu sh_sourceCode" style="display: none;"><pre><a class="snippet-copy sh_url" href="http://c.biancheng.net/view/vip_7067.html#" style="display: none;">复制</a><a class="snippet-text sh_url" href="http://c.biancheng.net/view/vip_7067.html#">纯文本</a><a class="snippet-window sh_url" href="http://c.biancheng.net/view/vip_7067.html#">复制</a></pre></div><pre class="java sh_java snippet-formatted sh_sourceCode"><ol class="snippet-num"><li><span class="sh_keyword">public</span> <span class="sh_keyword">class</span><span class="sh_normal"> </span><span class="sh_classname">Animal</span> <span class="sh_cbracket">{</span></li><li>    <span class="sh_keyword">public</span> <span class="sh_type">void</span> <span class="sh_function">sleep</span><span class="sh_symbol">()</span> <span class="sh_cbracket">{</span></li><li>        System<span class="sh_symbol">.</span>out<span class="sh_symbol">.</span><span class="sh_function">println</span><span class="sh_symbol">(</span><span class="sh_string">"小动物在睡觉"</span><span class="sh_symbol">);</span></li><li>    <span class="sh_cbracket">}</span></li><li><span style="display:none;">&nbsp;</span></li><li>    <span class="sh_keyword">public</span> <span class="sh_keyword">static</span> <span class="sh_type">void</span> <span class="sh_function">doSleep</span><span class="sh_symbol">(</span><span class="sh_usertype">Animal</span><span class="sh_normal"> </span>animal<span class="sh_symbol">)</span> <span class="sh_cbracket">{</span></li><li>        <span class="sh_comment">// 此时的参数是父类对象，但是实际调用时传递的是子类对象，就是向上转型。</span></li><li>        animal<span class="sh_symbol">.</span><span class="sh_function">sleep</span><span class="sh_symbol">();</span></li><li>    <span class="sh_cbracket">}</span></li><li><span style="display:none;">&nbsp;</span></li><li>    <span class="sh_keyword">public</span> <span class="sh_keyword">static</span> <span class="sh_type">void</span> <span class="sh_function">main</span><span class="sh_symbol">(</span>String<span class="sh_symbol">[]</span> args<span class="sh_symbol">)</span> <span class="sh_cbracket">{</span></li><li>        animal<span class="sh_symbol">.</span><span class="sh_function">doSleep</span><span class="sh_symbol">(</span><span class="sh_keyword">new</span> <span class="sh_function">Cat</span><span class="sh_symbol">());</span></li><li>        animal<span class="sh_symbol">.</span><span class="sh_function">doSleep</span><span class="sh_symbol">(</span><span class="sh_keyword">new</span> <span class="sh_function">Dog</span><span class="sh_symbol">());</span></li><li>    <span class="sh_cbracket">}</span></li><li><span class="sh_cbracket">}</span></li></ol></pre><pre class="snippet-textonly sh_sourceCode" style="display:none;">public class Animal {
    public void sleep() {
        System.out.println("小动物在睡觉");
    }

    public static void doSleep(Animal animal) {
        // 此时的参数是父类对象，但是实际调用时传递的是子类对象，就是向上转型。
        animal.sleep();
    }

    public static void main(String[] args) {
        animal.doSleep(new Cat());
        animal.doSleep(new Dog());
    }
}
</pre></div></div>
子类 Cat 代码如下：
<div class="snippet-container" style="undefined;"><div class="sh_bright snippet-wrap"><div class="snippet-menu sh_sourceCode" style="display: none;"><pre><a class="snippet-copy sh_url" href="http://c.biancheng.net/view/vip_7067.html#" style="display: none;">复制</a><a class="snippet-text sh_url" href="http://c.biancheng.net/view/vip_7067.html#">纯文本</a><a class="snippet-window sh_url" href="http://c.biancheng.net/view/vip_7067.html#">复制</a></pre></div><pre class="java sh_java snippet-formatted sh_sourceCode"><ol class="snippet-num"><li><span class="sh_keyword">public</span> <span class="sh_keyword">class</span><span class="sh_normal"> </span><span class="sh_classname">Cat</span> <span class="sh_keyword">extends</span> Animal <span class="sh_cbracket">{</span></li><li>    @Override</li><li>    <span class="sh_keyword">public</span> <span class="sh_type">void</span> <span class="sh_function">sleep</span><span class="sh_symbol">()</span> <span class="sh_cbracket">{</span></li><li>        System<span class="sh_symbol">.</span>out<span class="sh_symbol">.</span><span class="sh_function">println</span><span class="sh_symbol">(</span><span class="sh_string">"猫正在睡觉"</span><span class="sh_symbol">);</span></li><li>    <span class="sh_cbracket">}</span></li><li><span class="sh_cbracket">}</span></li></ol></pre><pre class="snippet-textonly sh_sourceCode" style="display:none;">public class Cat extends Animal {
    @Override
    public void sleep() {
        System.out.println("猫正在睡觉");
    }
}
</pre></div></div>
子类 Dog 代码如下：
<div class="snippet-container" style="undefined;"><div class="sh_bright snippet-wrap"><div class="snippet-menu sh_sourceCode" style="display: none;"><pre><a class="snippet-copy sh_url" href="http://c.biancheng.net/view/vip_7067.html#" style="display: none;">复制</a><a class="snippet-text sh_url" href="http://c.biancheng.net/view/vip_7067.html#">纯文本</a><a class="snippet-window sh_url" href="http://c.biancheng.net/view/vip_7067.html#">复制</a></pre></div><pre class="java sh_java snippet-formatted sh_sourceCode"><ol class="snippet-num"><li><span class="sh_keyword">public</span> <span class="sh_keyword">class</span><span class="sh_normal"> </span><span class="sh_classname">Dog</span> <span class="sh_keyword">extends</span> Animal <span class="sh_cbracket">{</span></li><li>    @Override</li><li>    <span class="sh_keyword">public</span> <span class="sh_type">void</span> <span class="sh_function">sleep</span><span class="sh_symbol">()</span> <span class="sh_cbracket">{</span></li><li>        System<span class="sh_symbol">.</span>out<span class="sh_symbol">.</span><span class="sh_function">println</span><span class="sh_symbol">(</span><span class="sh_string">"狗正在睡觉"</span><span class="sh_symbol">);</span></li><li>    <span class="sh_cbracket">}</span></li><li><span class="sh_cbracket">}</span></li></ol></pre><pre class="snippet-textonly sh_sourceCode" style="display:none;">public class Dog extends Animal {
    @Override
    public void sleep() {
        System.out.println("狗正在睡觉");
    }
}</pre></div></div>
输出结果为：
<p class="info-box">
	猫正在睡觉<br>
	狗正在睡觉</p>
如果不用向上转型则必须写两个 doSleep 方法，一个传递 Cat 类对象，一个传递 Dog 类对象。这还是两个子类，如果有多个子类就要写很多相同的方法，造成重复。可以看出向上转型更好的体现了类的多态性，增强了程序的间接性以及提高了代码的可扩展性。当需要用到子类特有的方法时可以向下转型，这也就是为什么要向下转型。<br>
<br>
比如设计一个父类 FileRead 用来读取文件，ExcelRead 类和 WordRead 类继承 FileRead 类。在使用程序的时候，往往事先不知道我们要读入的是 Excel 还是 Word。所以我们向上转型用父类去接收，然后在父类中实现自动绑定，这样无论你传进来的是 Excel 还是 Word 就都能够完成文件读取。<br>
<br>
总结如下：<br>
<ol>
	<li>
		把子类对象直接赋给父类引用是向上转型，向上转型自动转换。如 Father father = new Son();</li>
	<li>
		指向子类对象的父类引用赋给子类引用是向下转型，要强制转换。使用向下转型，必须先向上转型，为了安全可以用 instanceof 运算符判断。&nbsp;如 father 是一个指向子类对象的父类引用，把 father 赋给子类引用 son，即<code> Son son =（Son）father;</code>。其中 father 前面的<code>(Son)</code>必须添加，进行强制转换。</li>
	<li>
		向上转型不能使用子类特有的属性和方法，只能引用父类的属性和方法，但是子类重写父类的方法是有效的。</li>
	<li>
		向上转型时会优先使用子类中重写父类的方法，如例 1 中调用的 sleep 方法。</li>
	<li>
		向上转型的作用是减少重复代码，可以将父类作为参数，这样使代码变得简洁，也更好的体现了多态。</li>
</ol>
</div>
			<div id="arc-append">
	<p>关注微信公众号「站长严长生」，在手机上阅读所有教程，随时随地都能学习。本公众号由<a class="col-link" href="http://c.biancheng.net/view/8092.html" target="_blank" rel="nofollow">C语言中文网站长</a>运营，每日更新，坚持原创，敢说真话，凡事有态度。</p>
	<p style="margin-top:12px; text-align:center;">
		<img width="180" src="./9.6Java中为什么使用向上转型而不直接创建子类对象？_files/qrcode_weixueyuan_original.png" alt="魏雪原二维码"><br>
		<span class="col-green">微信扫描二维码关注公众号</span>
	</p>
</div>
<!-- <p>关注微信公众号「魏雪原」，跟着<a class="col-link" href="/view/8092.html" target="_blank">站长</a>一起学习，拒绝躺平，跳出内卷，用知识完成阶级跃升：</p>
	<ul>
		<li>每日更新，坚持原创，敢说真话，凡事有态度。</li>
		<li>编程+求职+创业+营销，既有硬知识，也有软技能。</li>
		<li>手机端阅读教程，随时随地都能学习。</li>
		<li>即将绑定网站部分功能，包括注册登录、找回密码、获取下载链接等。</li>
	</ul> -->
			<div class="pre-next-page clearfix">
                    <span class="pre left"><span class="icon">&lt;</span> <span class="text-brief text-brief-pre">上一页</span><a href="http://c.biancheng.net/view/6503.html">Java对象类型转换</a></span>
                    <span class="next right"><a href="http://c.biancheng.net/view/998.html">Java方法重载</a><span class="text-brief text-brief-next">下一页</span> <span class="icon">&gt;</span></span>
                </div>
			<div id="ad-arc-bottom"></div>

<!-- <div id="ad-bottom-weixin" class="clearfix">
	<div class="left" style="width: 535px;">
		<p><span class="col-red">编程帮</span>，一个分享编程知识的公众号。跟着<a class="col-link" href="/cpp/about/author/" target="_blank">站长</a>一起学习，每天都有进步。</p>
		<p>通俗易懂，深入浅出，一篇文章只讲一个知识点。</p>
		<p>文章不深奥，不需要钻研，在公交、在地铁、在厕所都可以阅读，随时随地涨姿势。</p>
		<p>文章不涉及代码，不烧脑细胞，人人都可以学习。</p>
		<p>当你决定关注「编程帮」，你已然超越了90%的程序员！</p>
	</div>
	<div class="right" style="width: 150px;">
		<img width="150" src="/templets/new/images/erweima_biancheng.gif?v=1.6.72" alt="编程帮二维码" /><br />
		<span class="col-green">微信扫描二维码关注</span>
	</div>
</div> -->

<div id="nice-arcs" class="box-bottom">
	<h4>优秀文章</h4>
	<ul class="clearfix">
<li><a href="http://c.biancheng.net/view/320.html" title="C++类模板（模板类）详解">C++类模板（模板类）详解</a></li>
<li><a href="http://c.biancheng.net/view/1176.html" title="Java getId()方法的作用">Java getId()方法的作用</a></li>
<li><a href="http://c.biancheng.net/view/4478.html" title="Json数据编码和解码">Json数据编码和解码</a></li>
<li><a href="http://c.biancheng.net/view/4630.html" title="SpringBoot是什么？SpringBoot的优缺点有哪些？">SpringBoot是什么？SpringBoot的优缺点有哪些？</a></li>
<li><a href="http://c.biancheng.net/view/5499.html" title="JWT（Json Web Token）是什么？">JWT（Json Web Token）是什么？</a></li>
<li><a href="http://c.biancheng.net/view/6734.html" title="Java 7新特性：多异常捕获">Java 7新特性：多异常捕获</a></li>
<li><a href="http://c.biancheng.net/view/7485.html" title="C++ merge()和inplace_merge()函数用法（详解版）">C++ merge()和inplace_merge()函数用法（详解版）</a></li>
<li><a href="http://c.biancheng.net/view/8180.html" title="JS定时器实现图片轮播">JS定时器实现图片轮播</a></li>
<li><a href="http://c.biancheng.net/spring/bean-life-cycle.html" title="Spring Bean生命周期">Spring Bean生命周期</a></li>
<li><a href="http://c.biancheng.net/redis2/zscore.html" title="Redis ZSCORE命令">Redis ZSCORE命令</a></li>
</ul>
</div>
		</div>
		
	</div>
</div>
<script type="text/javascript">
// 当前文章ID
window.arcIdRaw = 'a_' + 7067;
window.arcId = "b903Ugup5mNEuPEpSFfr43VpeGTY8+bqFPS2ooy29IIdfYNaMjMLY5GTeEs";
window.typeidChain = "100|79";
</script>
<div id="footer" class="clearfix">
	<div class="info left">
	<p>精美而实用的网站，分享优质编程教程，帮助有志青年。千锤百炼，只为大作；精益求精，处处斟酌；这种教程，看一眼就倾心。</p>
	<p>
		<a href="http://c.biancheng.net/view/8066.html" target="_blank" rel="nofollow">关于网站</a> <span>|</span>
		<a href="http://c.biancheng.net/view/8092.html" target="_blank" rel="nofollow">关于站长</a> <span>|</span>
		<a href="http://c.biancheng.net/view/8097.html" target="_blank" rel="nofollow">如何完成一部教程</a> <span>|</span>
		<a href="http://c.biancheng.net/view/8093.html" target="_blank" rel="nofollow">联系我们</a> <span>|</span>
		<a href="http://c.biancheng.net/sitemap/" target="_blank" rel="nofollow">网站地图</a>
	</p>
	<p>Copyright ©2012-2021 biancheng.net, <a href="http://www.beian.miit.gov.cn/" target="_blank" rel="nofollow" style="color:#666;">陕ICP备15000209号</a></p>
	</div>
	<img class="right" src="./9.6Java中为什么使用向上转型而不直接创建子类对象？_files/logo_bottom.gif" alt="底部Logo">
	<span id="return-top"><b>↑</b></span>
</div>

<script type="text/javascript">
window.siteId = 4;
window.cmsTemplets = "/templets/new";
window.cmsTempletsVer = "1.6.72";
</script>

<script src="./9.6Java中为什么使用向上转型而不直接创建子类对象？_files/jquery1.12.4.min.js.下载"></script>
<script src="./9.6Java中为什么使用向上转型而不直接创建子类对象？_files/common.js.下载"></script>
<span style="display:none;"><script src="./9.6Java中为什么使用向上转型而不直接创建子类对象？_files/z_stat.php" type="text/javascript" defer="defer" async="async"></script></span>

</body></html>